package com.suoluo.zenadmin.dao.classify;

import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;

import com.suoluo.zenadmin.vo.classify.HomeStyleVO;
import com.suoluo.zenadmin.vo.dest.DestFeatureItem2VO;

@DAO
public interface StyleDAO {

	@SQL("SELECT * FROM tb_home_style_item limit :1,:2")
	public List<HomeStyleVO> findListStyleHomeItem(int start,int rows);
	
	@SQL("insert into tb_home_style_item(t_feature_category_id,t_feature_category_name," +
			"t_style_count,t_style_orig_img) " +
			"values(:1.featureCategoryId,:1.featureCategoryName,:1.styleCount,:1.styleOrigImg)")
	public void saveStyle(HomeStyleVO styleVO);
	
	@SQL("select * from tb_home_style_item where t_home_style_id=:1")
	public HomeStyleVO findHomeStyleItemById(int styleId);
	
	@SQL("update tb_home_style_item set t_style_orig_img=:1.styleOrigImg " +
			"where t_home_style_id=:1.homeStyleId")
	public void updateStyle(HomeStyleVO styleVO);
	
	@SQL("delete from tb_home_style_item where t_home_style_id=:1")
	public void deleteStyle(int homeStyleId);
	
	@SQL("update tb_home_style_item set t_style_count =:2 where t_home_style_id =:1")
	public void updateStyleCount(int homeStyleId,int categoryCount);
	
	
	@SQL("select count(t_home_style_id) " +
					"from tb_home_style_item where t_feature_category_id =:1 ")
	public int findStyleHomeCategoryByCategoryId(int featureCategoryId);
	
	@SQL("select count(feature_item_id) " +
					"from tb_dest_feature_item2 where feature_id in " +
					"(select feature_id from tb_dest_feature2 " +
					"where feature_category_id in (select t_feature_category_id " +
					"from tb_dest_feature_category where " +
					"t_feature_category_id =:1 or t_feature_parent_category_id=:1))")
	public int findFeatureCategoryCount(int featureCategoryId);
	
	@SQL("SELECT count(t_home_style_id) FROM tb_home_style_item")
	public int findHomeStyleCount();
	
	
	@SQL("select t1.*,t3.* from tb_dest_feature_item2 t1 " +
			"join tb_dest_feature_category t2 on t2.t_feature_category_id = t1.feature_category_id " +
			"join tb_image t3 on t3.image_id = t1.image_id " +
			"where (t2.t_feature_category_id =:1 or t2.t_feature_parent_category_id =:1) and t1.deleted = 0 " +
			"order by t1.feature_item_id desc limit :2,:3")
	public List<DestFeatureItem2VO> findFeatureItemByCategoryId (int featureCategoryId,int startPos,int endPos);
	
	@SQL("select count(*) from  tb_dest_feature_item2 t1 "
				+ "join tb_dest_feature_category t2 on t2.t_feature_category_id = t1.feature_category_id "
				+ "where  (t2.t_feature_category_id =:1 or t2.t_feature_parent_category_id =:1) and t1.deleted = 0")
	public int findFeatureItemCountByCategoryId(int featureCategoryId);
	
}
